package com.amiba.crm.admin.common.util;

import cn.hutool.core.util.IdUtil;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class RandomUtil {
    /**
     * 年月日时分秒(无下划线) yyMMddHHmmss
     */
    public static final String TIME_FORMAT = "yyMMdd";

    public static String getIds() {
        String id = IdUtil.createSnowflake(1, 1).nextId() + "";
        return id.substring(id.length() - 6, id.length());
    }

    public static String getOrderSn() {
        Date date = new Date();
        DateFormat df = new SimpleDateFormat(TIME_FORMAT);
        String sn = df.format(date);
        return sn + getIds();
    }

}
